package com.sk.bilibili.model.fragment.main;

import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.FileUtils;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.mapper.HistoryMapper;
import com.sk.bilibili.model.BaseModel;
import com.sk.bilibili.other.JsonMap;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.main.HistoryFragment;
import com.sk.bilibili.view.fragment.main.SaveFragment;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import lombok.SneakyThrows;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;

public class SaveModel extends BaseModel<SaveFragment> {

    @Autowired
    OkHttpClient client;

    public void downloadTest(Context context) {
//        Log.e("TEST", "--------------------------------------------------------------");
//        new Thread(()->{
//            try {
//                InputStream is = client.newCall(new Request.Builder().url("https://i0.hdslb.com/bfs/bangumi/image/9f48bffa630673347f366c87baf98885a3ac46f6.png@2320w_664h.png").get().build())
//                        .execute().body().byteStream();
//                File dir = context.getFilesDir();
//                Log.e("TEST",dir.getAbsolutePath());
//                FileOutputStream os = new FileOutputStream(new File(dir, "test111.png"));
//                FileUtils.copy(is,os);
//                Log.e("TEST","下载完毕");
//                File file = new File(dir, "test111.png");
//                Log.e("TEST",file.exists()+"111111111111111111");
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }).start();
    }

}